/**
 * 
 */
package com.nari.baseinfo.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.nari.baseinfo.dao.IBuildingDao;
import com.nari.baseinfo.dao.IBuildingUnitDao;
import com.nari.baseinfo.dao.ICommunityDao;
import com.nari.baseinfo.dao.IHeatRoomDao;
import com.nari.baseinfo.dao.IShareAreaDao;
import com.nari.baseinfo.model.IBuilding;
import com.nari.baseinfo.model.IBuildingUnit;
import com.nari.baseinfo.model.IHeatRoom;
import com.nari.baseinfo.model.IShareArea;
import com.nari.baseinfo.utils.IBuildingFloorEntity;
import com.nari.coreframe.service.GenericServiceImpl;
import com.nari.platform.components.dhtmltree.DhtmlTreeNode;
import com.nari.platform.components.dhtmltree.TreeUserData;
import com.nari.platform.model.PageCond;
import com.nari.platform.model.ResponseMsg;
import com.nari.platform.model.ResultWithPageCond;

/**
 * 
 * @author Xiaopeng
 * @date 2013-8-1
 */
public class HeatRoomServiceImpl extends GenericServiceImpl<IHeatRoom, String>
		implements IHeatRoomService {
	private IBuildingDao iBuildingDao;
	private IBuildingUnitDao iBuildingUnitDao;
	private ICommunityDao iCommunityDao;
	private IShareAreaDao iShareAreaDao;

	/**
	 * 分页查询热用户列表
	 * @param houseNo 门牌号(可选)
	 * @param roomOwner 户主姓名(可选)
	 * @param projectUID 所属项目(可选)
	 * @param communityUID 所属小区(可选)
	 * @param pageCond
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-8-26
	 */
	public ResultWithPageCond<IHeatRoom> queryHeatRoomPage(String houseNo,
			String roomOwner, String projectUID, String communityUID,
			PageCond pageCond) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.queryHeatRoomPage(houseNo, roomOwner, projectUID, communityUID, pageCond);
	}

	/**
	 * 通过热用户列表查询与之关联的小区ID-小区名称映射表
	 * @param projectList 热用户列表，若列表为空，则返回空的映射表
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-8-6
	 */
	public Map<String, String> queryReferCommunitysByRoomList(List<IHeatRoom> roomList) throws Exception {
		List<String> communityIDList = null;
		if (roomList != null && roomList.size() > 0) {
			communityIDList = new ArrayList<String>();
			for (IHeatRoom heatRoom : roomList) {
				communityIDList.add(heatRoom.getCommunityID());
			}
		}
		return iCommunityDao.queryIdNameMapByIDList(communityIDList);
	}

	/**
	 * 通过热用户列表查询与之关联的楼栋ID-楼栋名称映射表
	 * 
	 * @param projectList
	 *            热用户列表，若列表为空，则返回空的映射表
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-8-6
	 */
	public Map<String, String> queryReferBuildingsByRoomList(
			List<IHeatRoom> roomList) throws Exception {
		List<String> buildingIDList = null;
		if (roomList != null && roomList.size() > 0) {
			buildingIDList = new ArrayList<String>();
			for (IHeatRoom heatRoom : roomList) {
				buildingIDList.add(heatRoom.getBuildingID());
			}
		}
		return iBuildingDao.queryIdNameMapByIDList(buildingIDList);
	}

	/**
	 * 通过热用户列表查询与之关联的楼栋单元ID-楼栋单元名称映射表
	 * 
	 * @param projectList
	 *            热用户列表，若列表为空，则返回空的映射表
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-8-6
	 */
	public Map<String, String> queryReferBuildingUnitsByRoomList(
			List<IHeatRoom> roomList) throws Exception {
		List<String> buildingUnitIDList = null;
		if (roomList != null && roomList.size() > 0) {
			buildingUnitIDList = new ArrayList<String>();
			for (IHeatRoom heatRoom : roomList) {
				buildingUnitIDList.add(heatRoom.getUnitID());
			}
		}
		return iBuildingUnitDao.queryIdNameMapByIDList(buildingUnitIDList);
	}

	/**
	 * 通过热用户所属关系(所属项目、所属楼栋、所属分摊域)查询热用户列表 
	 * 若项目ID、楼栋ID、分摊域ID均不存在，则返回空列表
	 * @param projectUID 项目ID(可选)
	 * @param communityUID 所属小区(可选)
	 * @param shareAreaUID 分摊域ID(可选)
	 * @param buildingUID 楼栋ID(可选)
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-8-19
	 */
	public List<IHeatRoom> queryHeatRoomsByBelongs(String projectUID, String communityUID, 
			String shareAreaUID, String buildingUID) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.queryHeatRoomsByBelongs(projectUID, communityUID, shareAreaUID, buildingUID);
	}
	
	/**
	 * 通过热用户所属关系(所属项目、所属楼栋、所属分摊域)查询热用户列表
	 * 若项目ID、楼栋ID、分摊域ID均不存在，则返回空列表
	 * @param projectUID 项目ID(可选)
	 * @param communityUID 所属小区(可选)
	 * @param shareAreaUID 分摊域ID(可选)
	 * @param buildingUID 楼栋ID(可选)
	 * @param ifMeasureCharge 是否参与分摊(可选)
	 * 1:不参与		2:参与
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2014-4-30
	 */
	public List<IHeatRoom> queryHeatRoomsByBelongs(String projectUID, String communityUID,
			String shareAreaUID, String buildingUID, Integer ifMeasureCharge) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.queryHeatRoomsByBelongs(projectUID, communityUID, shareAreaUID, buildingUID, ifMeasureCharge);
	}

	/**
	 * 通过热用户ID列表查询热用户信息
	 * @param idList 热用户ID列表，若ID列表为空，则返回空
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-8-13
	 */
	public List<IHeatRoom> queryHeatRoomsByIDList(List<String> idList) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.queryHeatRoomsByIDList(idList);
	}

	/**
	 * 通过分摊域等信息分页查询热用户列表
	 * @param shareAreaUID 所属分摊域(必选)
	 * 说明：若分摊域ID不存在，则返回零结果集
	 * @param houseNo 热用户门牌号(可选)
	 * @param projectUID 所属项目(可选)
	 * @param communityUID 所属小区(可选)
	 * @param buildingUID 所属楼栋(可选)
	 * @param pageCond
	 * @return
	 * @author Xiaopeng
	 * @date 2013-8-21
	 */
	public ResultWithPageCond<IHeatRoom> queryHeatRoomPageByAreaUID(String shareAreaUID, 
			String houseNo, String projectUID, String communityUID, String buildingUID, 
			PageCond pageCond) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.queryHeatRoomPageByAreaUID(shareAreaUID, houseNo, projectUID, communityUID, buildingUID, pageCond);
	}

	/**
	 * 查询不隶属于某个分摊域下的热用户列表
	 * @param shareAreaUID 所属分摊域(必选)
	 * 说明：若分摊域ID不存在，则返回零结果集
	 * @param projectUID 所属项目(可选)
	 * @param communityUID 所属小区(可选)
	 * @param buildingUID 所属楼栋(可选)
	 * @param houseNo 热用户门牌号(可选)
	 * @param pageCond
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-9-3
	 */
	public ResultWithPageCond<IHeatRoom> queryRoomPageExceptAreaUID(String shareAreaUID, 
			String projectUID, String communityUID, String buildingUID,String houseNo, 
			PageCond pageCond) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.queryRoomPageExceptAreaUID(shareAreaUID, projectUID, communityUID, buildingUID, houseNo, pageCond);
	}
	
	/**
	 * 批量设置热用户所属分摊域信息
	 * @param shareAreaUID 所属分摊域
	 * @param roomIDList 热用户ID列表，格式：XXX,XXX,XXX
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-9-3
	 */
	public ResponseMsg saveHeatRoomArea(String shareAreaUID, String roomIDList) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.saveHeatRoomArea(shareAreaUID, roomIDList);
	}
	
	/**
	 * 通过所属分摊域统计热用户数量
	 * @param shareAreaUID
	 * @param ifMeasureCharge
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-9-6
	 */
	public int countHeatRoomsByAreaUID(String shareAreaUID, 
			Integer ifMeasureCharge) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.countHeatRoomsByAreaUID(shareAreaUID, ifMeasureCharge);
	}
	
	/**
	 * 通过所属分摊域统计热用户建筑面积之和
	 * @param shareAreaUID
	 * @param ifMeasureCharge
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-9-6
	 */
	public double sumRoomStructAreaByAreaUID(String shareAreaUID, 
			Integer ifMeasureCharge) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.sumRoomStructAreaByAreaUID(shareAreaUID, ifMeasureCharge);
	}
	
	/**
	 * 通过所属分摊域统计热用户供热面积之和
	 * @param shareAreaUID
	 * @param ifMeasureCharge
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-9-6
	 */
	public double sumRoomHeatAreaByAreaUID(String shareAreaUID, 
			Integer ifMeasureCharge) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.sumRoomHeatAreaByAreaUID(shareAreaUID, ifMeasureCharge);
	}
	
	/**
	 * 通过所属楼栋统计热用户供热面积之和
	 * @param buildingUID
	 * @param ifMeasureCharge
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-9-6
	 */
	public double sumRoomHeatAreaByBuildingUID(String buildingUID, 
			Integer ifMeasureCharge) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.sumRoomHeatAreaByBuildingUID(buildingUID, ifMeasureCharge);
	}
	
	/**
	 * 根据热用户所属关系统计热用户的个数
	 * @param projectUID 所属项目(可选)
	 * @param communityUID 所属小区(可选)
	 * @param buildingUID 所属楼栋(可选)
	 * @param shareAreaUID 所属分摊域(可选)
	 * @param ifMeasureCharge 是否参与计量收费(可选)
	 * @return
	 * @author Xiaopeng
	 * @date 2013-10-21
	 */
	public int countRoomSumByBelongs(String projectUID, String communityUID, String buildingUID, 
			String shareAreaUID, Integer ifMeasureCharge) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.countRoomSumByBelongs(projectUID, communityUID, buildingUID, shareAreaUID, ifMeasureCharge);
	}
	
	/**
	 * 根据热用户所属关系统计热用户的建筑面积之和
	 * @param projectUID 所属项目(可选)
	 * @param communityUID 所属小区(可选)
	 * @param buildingUID 所属楼栋(可选)
	 * @param shareAreaUID 所属分摊域(可选)
	 * @param ifMeasureCharge 是否参与计量收费(可选)
	 * @return
	 * @author Xiaopeng
	 * @date 2013-10-21
	 */
	public double sumRoomStructAreaByBelongs(String projectUID, String communityUID, String buildingUID, 
			String shareAreaUID, Integer ifMeasureCharge) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.sumRoomStructAreaByBelongs(projectUID, communityUID, buildingUID, shareAreaUID, ifMeasureCharge);
	}
	
	/**
	 * 根据分摊域所属信息查询对应的楼栋用户结构树
	 * 楼栋用户结构树：
	 * 楼栋1
	 *   |-----单元11
	 *   |       |--楼层11
	 *   |       |    |--热用户11
	 *   |       |    |--热用户12
	 *   |       |    |--....
	 *   |       |--楼层12
	 *   |       |    |--....
	 *   |     单元12
	 *   |       |--.........
	 * 楼栋2
	 *   |-----单元21
	 *   |       |--楼层21
	 *   |       |    |--热用户21
	 *   |       |    |--热用户22
	 *   |       |    |--....
	 *   |     单元22
	 *   |       |--.........
	 *   ....................
	 * @param shareAreaUID 所属分摊域
	 * @param parentArchitectUID 上级节点ID
	 * @param parentArchitectType 上级节点类型
	 * 说明：building:楼栋	unit:单元	floor:楼层	room:热用户	
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-12-20
	 */
	public DhtmlTreeNode queryRelatedRoomArchitect(String shareAreaUID, 
			String parentArchitectUID, String parentArchitectType) throws Exception {
		//构造楼栋用户结构树
		DhtmlTreeNode rootNode = this.queryRootArchitectNode(shareAreaUID, parentArchitectUID, parentArchitectType);
		if(shareAreaUID!=null && !"".equals(shareAreaUID)) {
			IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
			//查询分摊域所属楼栋ID列表
			String areaBuildingUIDList = iHeatRoomDao.queryBuidlingUIDListByAreaUID(shareAreaUID);
			//查询分摊域所属单元ID列表
			String areaUnitUIDList = iHeatRoomDao.queryUnitUIDListByAreaUID(shareAreaUID);
			//查询分摊域所属楼层ID列表
			String areaFloorUIDList = iHeatRoomDao.queryFloorUIDListByAreaUID(shareAreaUID);
			//查询分摊域所属热用户ID列表
			String areaRoomUIDList = iHeatRoomDao.queryRoomUIDListByAreaUID(shareAreaUID);
			//查询分摊域所属的项目、小区信息
			IShareArea shareArea = iShareAreaDao.queryEntityById(shareAreaUID);
			if(shareArea != null) {
				String projectUID = shareArea.getProjectID();
				String communityUID = shareArea.getCommunityID();
				//根据上级节点查询结构树下级节点
				if(parentArchitectUID!=null && !"".equals(parentArchitectUID)) {
					//父节点为楼栋，子节点为单元
					if("building".equals(parentArchitectType)) {
						List<IBuildingUnit> unitList = iBuildingUnitDao.queryUintListByBuildingUID(parentArchitectUID, null);
						if(unitList != null) {
							for(IBuildingUnit unit: unitList) {
								DhtmlTreeNode childNode = new DhtmlTreeNode();
								childNode.setId(unit.getId());
								childNode.setText(unit.getUnitName());
								childNode.getUserdata().add(new TreeUserData("nodeType", "unit"));
								if(areaUnitUIDList.indexOf(unit.getId()) >= 0) { //已设置分摊域的单元
									childNode.setChecked("1"); //选中节点
								}
								childNode.setOpen("true");
								//设置虚拟子节点，便于树节点自动展开
								DhtmlTreeNode cVitualNode = new DhtmlTreeNode();
								cVitualNode.setId("1");
								cVitualNode.setText("1");
								childNode.getItem().add(cVitualNode);
								//组装树结构
								rootNode.getItem().add(childNode);
							}
						}
					}
					//父节点为单元，子节点为楼层
					if("unit".equals(parentArchitectType)) {
						List<IBuildingFloorEntity> floorList = iHeatRoomDao.queryFloorListByUnitUID(parentArchitectUID);
						for(IBuildingFloorEntity floorEntity: floorList) {
							DhtmlTreeNode childNode = new DhtmlTreeNode();
							childNode.setId(floorEntity.getId());
							childNode.setText(floorEntity.getFloorIndex());
							childNode.getUserdata().add(new TreeUserData("nodeType", "floor"));
							if(areaFloorUIDList.indexOf(floorEntity.getId()) >= 0) { //已设置分摊域的楼层
								childNode.setChecked("1"); //选中节点
							}
							childNode.setOpen("true");
							//设置虚拟子节点，便于树节点自动展开
							DhtmlTreeNode cVitualNode = new DhtmlTreeNode();
							cVitualNode.setId("1");
							cVitualNode.setText("1");
							childNode.getItem().add(cVitualNode);
							//组装树结构
							rootNode.getItem().add(childNode);
						}
					}
					//父节点为楼层，子节点为热用户
					if("floor".equals(parentArchitectType)) {
						List<IHeatRoom> roomList = iHeatRoomDao.queryRoomListByFloorUID(parentArchitectUID);
						for(IHeatRoom room: roomList) {
							DhtmlTreeNode childNode = new DhtmlTreeNode();
							childNode.setId(room.getId());
							if(room.getRoomOwner()!=null && !"".equals(room.getRoomOwner())) {
								childNode.setText(room.getHouseNo()+"("+room.getRoomOwner()+")");
							} else {
								childNode.setText(room.getHouseNo());
							}
							childNode.getUserdata().add(new TreeUserData("nodeType", "room"));
							if(areaRoomUIDList.indexOf(room.getId()) >= 0) { //已设置分摊域的热用户
								childNode.setChecked("1"); //选中节点
							}
							childNode.setOpen("true");
							//设置虚拟子节点，便于树节点自动展开
							DhtmlTreeNode cVitualNode = new DhtmlTreeNode();
							cVitualNode.setId("1");
							cVitualNode.setText("1");
							childNode.getItem().add(cVitualNode);
							//组装树结构
							rootNode.getItem().add(childNode);
						}
					}
				} else { //查询项目、小区所属的楼栋列表
					List<IBuilding> buildingList = iBuildingDao.queryBuildingByBelongings(projectUID, communityUID);
					for(IBuilding building: buildingList) {
						DhtmlTreeNode childNode = new DhtmlTreeNode();
						childNode.setId(building.getId());
						childNode.setText(building.getBuildingID());
						childNode.getUserdata().add(new TreeUserData("nodeType", "building"));
						if(areaBuildingUIDList.indexOf(building.getId()) >= 0) { //已设置分摊域的楼栋
							childNode.setChecked("1"); //选中节点
						}
						childNode.setOpen("true");
						//设置虚拟子节点，便于树节点自动展开
						DhtmlTreeNode cVitualNode = new DhtmlTreeNode();
						cVitualNode.setId("1");
						cVitualNode.setText("1");
						childNode.getItem().add(cVitualNode);
						//组装树结构
						rootNode.getItem().add(childNode);
					}
				}
			}
		}
		return rootNode;
	}
	
	/**
	 * 构造楼栋用户结构树的根节点
	 * @param shareAreaUID 所属分摊域
	 * @param parentArchitectUID 上级节点ID
	 * @param parentArchitectType 上级节点类型
	 * 说明：building:楼栋	unit:单元	floor:楼层	room:热用户	
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-12-20
	 */
	private DhtmlTreeNode queryRootArchitectNode(String shareAreaUID, String parentArchitectUID, 
			String parentArchitectType) throws Exception {
		//构造楼栋用户结构树的根节点
		DhtmlTreeNode rootNode = new DhtmlTreeNode();
		rootNode.setId("0");
		rootNode.setText("0");
		rootNode.setOpen("1");
		if(shareAreaUID!=null && !"".equals(shareAreaUID)) {
			IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
			//查询分摊域所属楼栋ID列表
			String areaBuildingUIDList = iHeatRoomDao.queryBuidlingUIDListByAreaUID(shareAreaUID);
			//查询分摊域所属单元ID列表
			String areaUnitUIDList = iHeatRoomDao.queryUnitUIDListByAreaUID(shareAreaUID);
			//查询分摊域所属楼层ID列表
			String areaFloorUIDList = iHeatRoomDao.queryFloorUIDListByAreaUID(shareAreaUID);
			//查询分摊域所属热用户ID列表
			String areaRoomUIDList = iHeatRoomDao.queryRoomUIDListByAreaUID(shareAreaUID);
			//根据节点类型构造楼栋用户结构树的根节点
			if(parentArchitectUID!=null && !"".equals(parentArchitectUID)) {
				//楼栋
				if("building".equals(parentArchitectType)) {
					IBuilding building = iBuildingDao.queryEntityById(parentArchitectUID);
					//根节点设置
					rootNode.setId(building.getId());
					rootNode.setText(building.getBuildingID());
					rootNode.getUserdata().add(new TreeUserData("nodeType", "building"));
					if(areaBuildingUIDList.indexOf(parentArchitectUID) >= 0) { //已设置分摊域的楼栋
						rootNode.setChecked("1"); //选中节点
					}
					rootNode.setOpen("1");
				}
				//单元
				if("unit".equals(parentArchitectType)) {
					IBuildingUnit buildingUnit = iBuildingUnitDao.queryEntityById(parentArchitectUID);
					//根节点设置
					rootNode.setId(buildingUnit.getId());
					rootNode.setText(buildingUnit.getUnitName());
					rootNode.getUserdata().add(new TreeUserData("nodeType", "unit"));
					if(areaUnitUIDList.indexOf(parentArchitectUID) >= 0) { //已设置分摊域的单元
						rootNode.setChecked("1"); //选中节点
					}
					rootNode.setOpen("1");
				}
				//楼层
				if("floor".equals(parentArchitectType)) {
					//楼层ID编码分解所属楼栋、单元、楼层
					String[] belongArray = parentArchitectUID.split("[-]");
					String floorIndex = belongArray[2];
					//根节点设置
					rootNode.setId(parentArchitectUID);
					rootNode.setText(floorIndex);
					rootNode.getUserdata().add(new TreeUserData("nodeType", "floor"));
					if(areaFloorUIDList.indexOf(parentArchitectUID) >= 0) { //已设置分摊域的单元
						rootNode.setChecked("1"); //选中节点
					}
					rootNode.setOpen("1");
				}
				//热用户
				if("room".equals(parentArchitectType)) {
					IHeatRoom room = this.getiGenericDao().queryEntityById(parentArchitectUID);
					//根节点设置
					rootNode.setId(room.getId());
					if(room.getRoomOwner()!=null && !"".equals(room.getRoomOwner())) {
						rootNode.setText(room.getHouseNo()+"("+room.getRoomOwner()+")");
					} else {
						rootNode.setText(room.getHouseNo());
					}
					rootNode.getUserdata().add(new TreeUserData("nodeType", "room"));
					if(areaRoomUIDList.indexOf(parentArchitectUID) >= 0) { //已设置分摊域的热用户
						rootNode.setChecked("1"); //选中节点
					}
					rootNode.setOpen("1");
				}
			}
		}
		return rootNode;
	}
	
	/**
	 * 设置热用户所属的分摊域
	 * @param shareAreaUID
	 * @param roomIDList
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-12-20
	 */
	public ResponseMsg saveAreaRoomArchitect(String shareAreaUID, String roomIDList) throws Exception {
		if(shareAreaUID!=null && !"".equals(shareAreaUID)) {
			IShareArea shareArea = iShareAreaDao.queryEntityById(shareAreaUID);
			if(shareArea != null) {
				String projectUID = shareArea.getProjectID();
				String communityUID = shareArea.getCommunityID();
				//取消分摊域所属范围（项目、小区）内热用户的分摊域信息
				IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
				iHeatRoomDao.deleteAreaRoomArchitect(projectUID, communityUID, shareAreaUID, roomIDList);
				//设置热用户所属的分摊域
				iHeatRoomDao.saveAreaRoomArchitect(shareAreaUID, roomIDList);
				return ResponseMsg.getInstance(true, "");
			}
		}
		return ResponseMsg.getInstance(false, "请选择需要编辑的分摊域！");
	}
	
	/**
	 * 根据热用户ID级联删除关联信息
	 * 包括：热用户、系统用户及角色、分配表、散热器、用户分摊账单
	 * 注意：热量表数据、分配表数据等表计数据具有不可恢复性，因此不能作为级联删除的对象
	 * @param roomUID
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2014-1-20
	 */
	public ResponseMsg deleteCascadeByRoomUID(String roomUID) throws Exception {
		IHeatRoomDao iHeatRoomDao = (IHeatRoomDao) this.getiGenericDao();
		return iHeatRoomDao.deleteCascadeByRoomUID(roomUID);
	}
	
	/**
	 * @return the iBuildingDao
	 */
	public IBuildingDao getiBuildingDao() {
		return iBuildingDao;
	}

	/**
	 * @param iBuildingDao
	 *            the iBuildingDao to set
	 */
	public void setiBuildingDao(IBuildingDao iBuildingDao) {
		this.iBuildingDao = iBuildingDao;
	}

	/**
	 * @return the iBuildingUnitDao
	 */
	public IBuildingUnitDao getiBuildingUnitDao() {
		return iBuildingUnitDao;
	}

	/**
	 * @param iBuildingUnitDao
	 *            the iBuildingUnitDao to set
	 */
	public void setiBuildingUnitDao(IBuildingUnitDao iBuildingUnitDao) {
		this.iBuildingUnitDao = iBuildingUnitDao;
	}

	/**
	 * @return the iCommunityDao
	 */
	public ICommunityDao getiCommunityDao() {
		return iCommunityDao;
	}

	/**
	 * @param iCommunityDao the iCommunityDao to set
	 */
	public void setiCommunityDao(ICommunityDao iCommunityDao) {
		this.iCommunityDao = iCommunityDao;
	}
	
	/**
	 * @return the iShareAreaDao
	 */
	public IShareAreaDao getiShareAreaDao() {
		return iShareAreaDao;
	}

	/**
	 * @param iShareAreaDao the iShareAreaDao to set
	 */
	public void setiShareAreaDao(IShareAreaDao iShareAreaDao) {
		this.iShareAreaDao = iShareAreaDao;
	}

}
